package close.mazegame.entity;

import close.mazegame.level.Level;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;

//An entity with a representation in the box2d physics world
public abstract class PhysicsEntity extends Entity {
	
	protected Body body;
	
	//0x0001 is the default value for category bits, so we skip that one
	public enum EntityCategory {
		MOB(0x0002),
		PLAYER(0x0004),
		SOLIDTILE(0x0008),
		PROJECTILE(0x0016);
		
		private final short bits;
		EntityCategory(int bits) { this.bits = (short)bits; }
		public short getBits() { return bits; }
	}
	
	public PhysicsEntity(Level level) {
		super(level);
	}
	
	public float getMass() {
		return getBody().getMass();
	}
	
	public Body getBody() {
		return body;
	}
	
	public void dispose() {
		level.removeBody(getBody());
	}
	
	public Vector2 getVelocity() {
		return getBody().getLinearVelocity();
	}
	
	@Override
	public float getX() {
		return body.getPosition().x;
	}

	@Override
	public float getY() {
		return body.getPosition().y;
	}
	
	public Vector2 getPosition() {
		return body.getPosition();
	}

	@Override
	public float getAngle() {
		return body.getAngle();
	}

}
